//Unit test for initializeGame

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <assert.h>

#define _NUM_TESTS 100

int main() {
    unsigned int seed = (unsigned int) time(NULL);
    srand(seed);

    struct gameState state;
    int k1 = rand() % 27;
    int k2 = rand() % 27;
    int k3 = rand() % 27;
    int k4 = rand() % 27;
    int k5 = rand() % 27;
    int k6 = rand() % 27;
    int k7 = rand() % 27;
    int k8 = rand() % 27;
    int k9 = rand() % 27;
    int k10 = rand() % 27;
    int numPlayers = rand() % 5;
    int* k = kingdomCards(k1, k2, k3, k4, k5, k6, k7, k8, k9, k10);
    
    int result = initializeGame(numPlayers, k, seed, &state);
	
	int test = 0;
	while(test++ != _NUM_TESTS) {
		if(result == 0) {
			assert(state.numPlayers == numPlayers);
			switch(state.numPlayers) {
			case 2:
				assert(state.supplyCount[curse] == 10);
				assert(state.supplyCount[estate] == 8);
				assert(state.supplyCount[duchy] == 8);
				assert(state.supplyCount[province] == 8);
				assert(state.supplyCount[copper] == 46);
				assert(state.supplyCount[silver] == 40);
				assert(state.supplyCount[gold] == 30);
				break;
			case 3:
				assert(state.supplyCount[curse] == 20);
				assert(state.supplyCount[estate] == 12);
				assert(state.supplyCount[duchy] == 12);
				assert(state.supplyCount[province] == 12);
				assert(state.supplyCount[copper] == 39);
				assert(state.supplyCount[silver] == 40);
				assert(state.supplyCount[gold] == 30);
				break;
			case 4:
				assert(state.supplyCount[curse] == 30);
				assert(state.supplyCount[estate] == 12);
				assert(state.supplyCount[duchy] == 12);
				assert(state.supplyCount[province] == 12);
				assert(state.supplyCount[copper] == 32);
				assert(state.supplyCount[silver] == 40);
				assert(state.supplyCount[gold] == 30);
				break;
			}
		}
	}

    printf("Passed.\n");
	
    return 0;
}
